//
//  CZTabBarController.swift
//  iosweibo11
//
//  Created by Apple on 16/7/18.
//  Copyright © 2016年 Apple. All rights reserved.
//

import UIKit

class CZTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

       
        
        
        
        let homeVC = CZHomeViewController()
        addChildViewController(homeVC, title: "主页", imageName: "tabbar_home")
        
        
        //设置标题和图片
        
      
        
        
        let messageVC = CZMessayViewController()
        
        addChildViewController(messageVC, title: "消息", imageName: "tabbar_message_center")
        
        
        
        
        let discoveryVC = CZDiscoveryController()
       addChildViewController(discoveryVC, title: "发现", imageName: "tabbar_discover")
        
        
        
        
        

        
        let profileVC = CZProfileViewController()
        
       addChildViewController(profileVC, title: "我", imageName: "tabbar_profile")
        
        
    
        
        
        
        
      
        

    }
    
    func addChildViewController(controllr:UIViewController,title:String,imageName:String){
    
    
      
        
        controllr.title = title
        
        controllr.tabBarItem.image = UIImage(named: imageName)
        
        let selectImage = imageName + "_selected"
        
//        controllr.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: UIControlStateSelected)  为何不能点进去选？？？
        
      
        controllr.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: UIControlState.Selected)
        
        
        
        controllr.tabBarItem.selectedImage = UIImage(named: selectImage)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
     addChildViewController(UINavigationController(rootViewController: controllr))
        
    
    }
    
    
    
    

 
}
